package com.shujia

object Code41ImplicitClazz {
  def main(args: Array[String]): Unit = {
    val stu =  ImpStu("黄小敏", 18, "大数据")
    stu.change()

//    new Change(stu)


//    teach(stu)
  }

  implicit class Change(impStu: ImpStu) {

    def change(): Unit = {
      println("学生经过学习，转变成老师...")
    }


    // 隐式转换函数在class中不能被直接调用
    implicit def changeTeacher(): ImpTeacher = {
        ImpTeacher(impStu.name,impStu.age,impStu.learn)
    }

  }

  def teach(teacher: ImpTeacher): Unit = {

    println(s"${teacher.name}正在教授${teacher.teach},今年${teacher.age}了")
  }

  object nextObject {

  }

}


